/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package air_hockey_v2.gui;

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

/**
 *
 * @author cooler
 */
public class JogoFrame extends JFrame {

    private int SCR_WIDTH = 808,
            SCR_HEIGHT = 608;
    private JMenuBar barraDeMenu;
    private JMenu menuJogo;
    private JMenuItem voltar;
    private JMenuItem pausar;
    private JogoPanel jogo;

    public JogoFrame(int difi) {
        super("Air Hockey");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setSize(SCR_WIDTH, SCR_HEIGHT);
        this.setResizable(false);

        barraDeMenu = new JMenuBar();
        menuJogo = new JMenu("Jogo");
        voltar = new JMenuItem("Voltar");
        pausar = new JMenuItem("Pausar");
        menuJogo.add(pausar);
        menuJogo.addSeparator();
        menuJogo.add(voltar);
        barraDeMenu.add(menuJogo);
        this.setJMenuBar(barraDeMenu);

        voltar.addActionListener(new OuvinteMenu());
        pausar.addActionListener(new OuvinteMenu());

        Container fc = this.getContentPane();
        jogo = new JogoPanel(difi);
        fc.add(jogo);

    }

    private class OuvinteMenu implements ActionListener {

        @Override
        public void actionPerformed(ActionEvent ae) {
            if (ae.getSource() == voltar) {
                dispose();
                jogo.getTimer().setRun(false);
            }
            if (ae.getSource() == pausar) {
                jogo.setPause(!jogo.isPause());
            }
        }
    }

    /**
     * @return the SCR_WIDTH
     */
    public int getSCR_WIDTH() {
        return SCR_WIDTH;
    }

    /**
     * @param SCR_WIDTH the SCR_WIDTH to set
     */
    public void setSCR_WIDTH(int SCR_WIDTH) {
        this.SCR_WIDTH = SCR_WIDTH;
    }

    /**
     * @return the SCR_HEIGHT
     */
    public int getSCR_HEIGHT() {
        return SCR_HEIGHT;
    }

    /**
     * @param SCR_HEIGHT the SCR_HEIGHT to set
     */
    public void setSCR_HEIGHT(int SCR_HEIGHT) {
        this.SCR_HEIGHT = SCR_HEIGHT;
    }
}
